<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Treatment extends Model
{
    use HasFactory;

    protected $table = 'treatments';

    public function getTreatmentList($field="",$val="",$is_show_home = false){

        if(!$field){
            return $this->get();
        }

        if($is_show_home){
            return $this->where($field,'=', $val)->where('is_show_home','=',1)->get();
        }else{
            return $this->where($field,'=', $val)->get();
        }
    }

    public function getTreatment($field, $val){
        return $this->where($field,'=',$val)->first();
    }

    public function searchTreatmentList($field,$val){
        return $this->where($field,'like',"%".$val."%")->get();
    }
}
